home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.093 < prev    next >
Encoding:
Text File  |  1992-07-15  |  11.1 KB  |  232 lines  |  [TEXT/GEOL]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. Apple IIgs
  6. #93: Compatible Printing
  7.  
  8. Revised by:    Matt Deatherage     May 1992
  9. Written by:    Matt Deatherage     September 1990
  10.  
  11. This Technical Note discusses printing on the Apple IIgs and how you can make
  12. your printing code more compatible.
  13.  
  14. CHANGES SINCE SEPTEMBER 1990:  Added a note about expecting print records to
  15. keep the same attributes across Print Manager calls.  Added the StyleWriter's
  16. iDev value.
  17. _____________________________________________________________________________
  18.  
  19.  
  20. HOW DOES PRINTING WORK ANYWAY?
  21.  
  22. There are, in general, two types of printing done on the Apple IIgs.  The
  23. first kind is "desktop" printing, which uses the Apple IIgs Print Manager to
  24. render images created by QuickDraw II onto an output device.  The other kind
  25. of printing is "text" printing, which is similar to the way classic Apple II
  26. applications print--you send ASCII text somewhere and a printer prints it as
  27. ASCII text.  This printing normally involves no graphics and is very quick.
  28.  
  29. This Note covers both types of printing, and by understanding the internals
  30. and the methods used to print, you can avoid compatibility headaches in the
  31. future.
  32.  
  33.  
  34. DESKTOP PRINTING
  35.  
  36. Desktop printing uses the Apple IIgs Print Manager.  The process is described
  37. in detail in the Print Manager chapter of the Apple IIgs Toolbox Reference,
  38. and usually consists of a simple print loop:
  39.  
  40.      Open a document (PrOpenDoc)
  41.           Open a page (PrOpenPage)
  42.           Draw or Image the page in your favorite way
  43.           Close the page (PrClosePage)
  44.           Repeat for each page
  45.      Close the document (PrCloseDoc)
  46.      Print the document if it's spooled (PrPicFile)
  47.  
  48. Note that you should ALWAYS call PrPicFile at the end of your print loop.  It
  49. completes the printing process, even for immediate or draft printing.
  50.  
  51. There's one real secret about the Print Manager that can cloud your
  52. understanding of printing--the Print Manager doesn't actually do anything.  It
  53. loads, unloads, and keeps track of printer drivers and port drivers and
  54. performs some necessary housekeeping, but that's about it.  Many people
  55. believe that the Print Manager is responsible for all imaging, managing
  56. documents, managing a printing grafPort and such, but it's not.  (The myth is
  57. perpetuated by the Toolbox Reference which refers to these functions as
  58. handled by the Print Manager.)  In fact, these functions are handled by
  59. printer drivers.
  60.  
  61. You actually call the printer driver for all of the routines in the print
  62. loop; all the Print Manager does is make sure the driver is loaded and
  63. dispatch to it.  Therefore, most of the compatibility issues you have with
  64. printing are not with the Print Manager, but with printer drivers.
  65.  
  66. DEALING WITH THE PRINT RECORD
  67.  
  68. It's the printer driver's job to get information about a printing job from the
  69. user (it's the printer driver that handles the style and job dialog boxes,
  70. since the Print Manager cannot generically know what style and job options any
  71. printer can support), keep track of it, and print the document using those
  72. settings.  Those settings are kept in a data structure associated with a
  73. document known as a print record.
  74.  
  75. Apple had only released two printer drivers at the time the first volume of
  76. the Toolbox Reference was published, and therefore the descriptions of the
  77. print record in that volume tend to be absolute.  For example, the iDev field
  78. is documented as "one for an ImageWriter and three for a LaserWriter."  In
  79. fact, the iDev field is the only method of print record interpretation
  80. available and there are several values for it:
  81.  
  82.      $0001 = ImageWriter
  83.      $0002 = ImageWriter LQ
  84.      $0003 = LaserWriter
  85.      $0004 = Epson
  86.      $0065 = StyleWriter
  87.      $8001 = Generic dot-matrix (interprets the style subrecord like the
  88.              ImageWriter driver)
  89.      $8003 = Generic laser printer (interprets the style subrecord like the
  90.              LaserWriter driver)
  91.  
  92. If you have checks in your code like "If it's not $0001, it must be a
  93. LaserWriter," you have problems with most of the other printer types.
  94.  
  95. The $8000 and greater iDev values are defined for third-party printer drivers.
  96. The printer driver has no way other than the print record to keep track of
  97. values for a given print job, so it has to store all such information in the
  98. print record.  If all third-party drivers use proprietary style subrecord
  99. formats, no applications can read or set any of those values.  Those drivers
  100. which can use the compatible $8000 and greater iDev values indicate to
  101. applications that the definitions in Toolbox Reference for the ImageWriter and
  102. LaserWriter drivers apply to these drivers as well.  iDev values of $0002 or
  103. $0004 also interpret the style subrecord as the ImageWriter driver does.
  104.  
  105. PRINT RECORD RULES
  106.  
  107. Remember:  the print record is the only way the printer driver has to maintain
  108. information about a particular job.  The print record belongs to the user, the
  109. document, and the printer driver--NOT the application.  Here are some rules
  110. for staying out of print record trouble.
  111.  
  112.    o   Always call PrValidate when changing fields in the print record.  Even
  113.        if a driver interprets the style subrecord like the ImageWriter
  114.        driver, it may not support all the ImageWriter's style features (e.g.,
  115.        color printing). Calling PrValidate every time you change something in
  116.        the print record gives the printer driver a chance to look at the
  117.        havoc you've wreaked and correct it if necessary.
  118.  
  119.        You do not always get a feature you want.  If a printer does not
  120.        support color printing, you can set the "color" bit all day long and
  121.        PrValidate clears it every time.  You should be prepared for a new
  122.        printer driver that does not support the features you want, and inform
  123.        the user that the feature is not supported by this printer.
  124.  
  125.    o   Do not patch PrValidate to make it ignore bogus values in the print
  126.        record unless instructed to do so by the printer driver author.
  127.  
  128.    o   Never, never tread on reserved fields in the print record.  If you
  129.        find a particular driver storing useful values some place, forget it.
  130.        This is the only place a driver has to store information about a print
  131.        job and some of it is not going to be supported.
  132.  
  133.        In particular, never try to interpret any values you may find in the
  134.        printX subrecord of the print record.  This subrecord is for the
  135.        private use of printer drivers.  Although printX is currently the
  136.        worst compatibility risk, you must not tamper with other reserved
  137.        fields.
  138.  
  139.    o   Don't assume that the print record will keep the same memory
  140.        attributes across calls to the Print Manager (and therefore the
  141.        printer driver). Specifically, don't assume that a print record will
  142.        stay locked across calls to the Print Manager.
  143.  
  144.    o   If you want to learn more about printing, learn how printer drivers
  145.        work. The specifications are in Apple IIgs Technical Note #35,
  146.        appropriately entitled "Printer Driver Specifications."  An
  147.        understanding of how printer drivers do their work is an understanding
  148.        of how printing works.
  149.  
  150.  
  151. TEXT PRINTING
  152.  
  153. Text printing generally uses the built-in ASCII mode of most dot-matrix
  154. printers to print text quickly and efficiently.
  155.  
  156. Desktop printer drivers often have a "draft" mode, where they print text
  157. immediately instead of imaging it in the appropriate font and style.  This is
  158. accomplished by intercepting low-level QuickDraw II routines called bottleneck
  159. procedures.  When QuickDraw is called to draw text, the printer driver gets
  160. control instead and sends the text to the printer.
  161.  
  162. Although this is useful to users of desktop printer drivers, it is not a
  163. required feature of any printer driver, and those that do implement it each do
  164. so in their individual way.  For example, the LaserWriter driver doesn't
  165. support this model of "draft" printing because the LaserWriter is normally a
  166. PostScript(R) device--sending straight ASCII to it doesn't necessarily work.
  167.  
  168. To imitate the way classic Apple II applications print, your application
  169. prompts the user for some device through which to print, and ASCII characters
  170. are sent through that device.  There are a few ways to do this.
  171.  
  172. USING THE PRINT MANAGER
  173.  
  174. You can still use the Print Manager to print in ASCII mode by bypassing the
  175. printer driver.  Simply use the Port Driver to send ASCII characters to the
  176. given target device with the PrDevWrite call.  The specifications for Port
  177. Driver calls are in Apple IIgs Technical Note #36, also appropriately entitled
  178. "Port Driver Specifications."  You make port driver calls as if they were
  179. Print Manager calls.
  180.  
  181. Although this method has been used, Apple does not recommend it.  If the
  182. selected port driver is a network driver, this method is troublesome.
  183.  
  184. USING THE TEXT TOOLS
  185.  
  186. By using the Apple IIgs Text Tools, you can ask the user what slot to print
  187. through and send ASCII characters to that slot or port.  Although this is
  188. better than using the Port Driver, it still has problems.  The Text Tools
  189. cannot be fully GS/OS Slot Arbiter compatible; therefore, there might be GS/OS
  190. devices accessible to the user to which your application does not let him
  191. print.  Also, it's difficult to detect which slots really have Text Tools'
  192. devices without knowing about Apple II firmware, and prompting the user for a
  193. slot number invites trying to print to the disk firwmare, which usually justs
  194. reboot the machine (unceremoniously).
  195.  
  196. USING GS/OS
  197.  
  198. GS/OS supports character drivers, such as printer interfaces, and using them
  199. is the best way to handle ASCII printing.  GS/OS supports loaded drivers for
  200. character devices if you have them, and generates drivers for character
  201. devices it can recognize.  In addition, GS/OS drivers have identification
  202. words so you can prompt with real messages instead of cryptic slot numbers.
  203.  
  204. You can use the GS/OS call DInfo to loop through all drivers and prepare a
  205. list of character drivers.  You can then change their device IDs into text
  206. phrases, place them in a list, and prompt the user to select one.  This call
  207. usually results in a list such as "Printer port, Modem port, Remote Print
  208. Manager, Printer interface, Text screen [the Console driver]."  You may wish
  209. to change the names of the devices slightly to make the choice easier (e.g.,
  210. "network printer" instead of "Remote Print Manager").
  211.  
  212. Apple strongly recommends using GS/OS for ASCII printing from 16-bit
  213. applications.
  214.  
  215.    NOTE : The Remote Print Manager (.RPM) device driver in System Software
  216.           5.0 to 5.0.2 has a bug which causes character loss.  System
  217.           Software 5.0.3 fixes this bug.
  218.  
  219.  
  220. Further Reference
  221. _____________________________________________________________________________
  222.  
  223.    o   Apple IIgs Toolbox Reference
  224.    o   GS/OS Reference
  225.    o   Apple IIgs Technical Note #34, Low-level QuickDraw II Routines
  226.    o   Apple IIgs Technical Note #35, Printer Driver Specifications
  227.    o   Apple IIgs Technical Note #36, Port Driver Specifications
  228.    o   Apple IIgs Technical Note #69, The Ins and Outs of Slot Arbitration
  229.    o   Apple IIgs Technical Note #75, BeginUpdate Anomaly
  230.  
  231. PostScript is a registered trademark of Adobe Systems Incorporated.
  232.